/*
 * Copyright 2007, 2008 Tiberiumlabs
 *
 * This file is part of Tiberiumlabs Lailaps.
 *
 * Tiberiumlabs Lailaps is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tiberiumlabs Lailaps is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.tiberiumlabs.lailaps.downloads;

import java.util.concurrent.atomic.AtomicLong;
import org.tiberiumlabs.lailaps.Mediator;
import org.tiberiumlabs.lailaps.actions.events.DataEvent;
import org.tiberiumlabs.lailaps.actions.events.DataListener;
import org.tiberiumlabs.lailaps.list.DownloadItem;
import org.tiberiumlabs.lailaps.list.StatusConstants;

/**
 *
 * @author <a href="paranoid.tiberiumlabs@gmail.com">Paranoid</a>
 */
public class DownloadThread implements DataListener, StatusConstants {

    private AtomicLong totalCompleted;
    private int needStatus = STOPPED;
    private int row;
    private final DownloadItem item;

    public DownloadThread(DownloadItem item, int row) {
        this.item = item;
        this.row = row;
    }

    public void dataChanged(DataEvent event) {
        row = event.calculateCurrentRow(row);
        if (row == -1) {
            row = Mediator.getMediator().getDownloadsListModel().indexOfItem(item);
        }
    }

    public int getRow() {
        return row;
    }

    public void setNeedStatus(int needStatus) {
        this.needStatus = needStatus;
    }

}
